from collections import deque
import heapq
from typing import List

n = int(input())
arr = list(range(510))
arr[0]=list()
for i in range(0,510):
    arr[0].append(-0x3f3f)
for i in range(1,510):
    arr[i]=list()
for i in range(1, n+1):
    nums = list(map(int, input().split()))
    arr[i].append(-0x3f3f)
    for item in nums:
        arr[i].append(item)
    arr[i].append(0)
arr[0][1]=0
p=2
for i in range(2, n+1):
    for j in range(1, p+1):
        arr[i][j] = max(arr[i - 1][j], arr[i-1][j - 1]) + arr[i][j]
    p+=1

ret=0
for item in arr[n]:
    ret=max(ret,item)
print(ret)
